package com.ruoyi.omp.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.omp.api.RemoteCheckMeterService;
import com.ruoyi.omp.api.domain.NyCheckMeter;
import com.ruoyi.omp.api.domain.NyMeterAccount;
import com.ruoyi.omp.api.domain.vo.EnterpriseVo;
import com.ruoyi.omp.api.domain.vo.NyCheckMeterVO;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

/**
 * 租赁记录降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteCheckMeterFactory implements FallbackFactory<RemoteCheckMeterService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteCheckMeterFactory.class);

    @Override
    public RemoteCheckMeterService create(Throwable throwable) {
        log.error("能源水电表服务调用失败:{}", throwable.getMessage());
        return new RemoteCheckMeterService() {

            @Override
            public R updateNyMeterAccount(NyMeterAccount nyMeterAccount) {
                return R.fail("更新仪表台账记录失败:" + throwable.getMessage());
            }

            @Override
            public R<List<NyMeterAccount>> listMeter(NyMeterAccount nyMeterAccount) {
                return R.fail("查询仪表台账记录失败:" + throwable.getMessage());
            }

            @Override
            public R<List<NyCheckMeterVO>> listCheckMeter(NyCheckMeter nyCheckMeter) {
                return R.fail("查询抄表记录失败:" + throwable.getMessage());
            }

            @Override
            public R<List<NyCheckMeterVO>> listCheckMonthShare(NyCheckMeter nyCheckMeter) {
                return R.fail("查询仪表分摊失败:" + throwable.getMessage());
            }

            @Override
            public R<BigDecimal> computePrivateSummery(NyCheckMeter nyCheckMeter) {
                return R.fail("私表汇总失败:" + throwable.getMessage());
            }

            @Override
            public R<NyCheckMeter> getCheckMeter(String recordId) {
                return R.fail("获取抄表记录失败:" + throwable.getMessage());
            }

            @Override
            public R updateCheckMeter(NyCheckMeter nyCheckMeter) {
                return R.fail("修改抄表记录失败:" + throwable.getMessage());
            }

            @Override
            public R<EnterpriseVo> getEenterprise(String id) {
                return R.fail("查询企业信息失败:" + throwable.getMessage());
            }

            @Override
            public R addEenterprise(EnterpriseVo enterpriseVo) {
                return R.fail("插入企业信息失败:" + throwable.getMessage());
            }

            @Override
            public R<String> getEenterpriseByName(String name) {
                return R.fail("查询企业失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> getIsCompleted(NyCheckMeter nyCheckMeter) {
                return R.fail("查询是否汇总失败:" + throwable.getMessage());
            }
        };


    }
}
